﻿using System;
using UnityEngine;

namespace H
{
	// Token: 0x0200026A RID: 618
	internal class H_State_Spurt : H_State
	{
		// Token: 0x0600103E RID: 4158 RVA: 0x000680AC File Offset: 0x000662AC
		public H_State_Spurt(H_Members members) : base(members)
		{
		}

		// Token: 0x0600103F RID: 4159 RVA: 0x000680D8 File Offset: 0x000662D8
		public override void In(H_State.Message msg)
		{
			this.members.param.manyEjaculation = (this.members.MaleGageVal >= 1f);
			this.xtcType = ((H_State_Spurt.SpurtMsg)msg).xtcType;
			this.members.param.xtcType = this.xtcType;
			this.members.PlayAnime("Spurt", 0.2f);
			this.members.SetSpeed(4f);
			H_Voice.TYPE voice = (this.xtcType != XTC_TYPE.XTC_F) ? H_Voice.TYPE.XTC_OMEN_M : H_Voice.TYPE.XTC_OMEN_F;
			this.members.VoiceExpression(voice);
			this.timer = 0f;
			this.seTimer = -1f;
		}

		// Token: 0x06001040 RID: 4160 RVA: 0x00068190 File Offset: 0x00066390
		public override void Main()
		{
			this.timer += Time.deltaTime;
			if (this.members.CheckEndVoice())
			{
				this.Next();
				return;
			}
			float num = this.members.input.Speed;
			num = ((num <= 0f) ? Mathf.Lerp(1f, this.minSpeed, -num) : Mathf.Lerp(1f, this.maxSpeed, num));
			this.UpdateSE(num);
		}

		// Token: 0x06001041 RID: 4161 RVA: 0x00068214 File Offset: 0x00066414
		public override void Out()
		{
			this.members.SetSpeed(1f);
		}

		// Token: 0x06001042 RID: 4162 RVA: 0x00068228 File Offset: 0x00066428
		private void Next()
		{
			H_STATE[] array = new H_STATE[]
			{
				H_STATE.NUM,
				H_STATE.IN_EJA_IN,
				H_STATE.OUT_EJA_IN,
				H_STATE.XTC_F_IN,
				H_STATE.XTC_W_IN
			};
			base.ChangeState(array[(int)this.xtcType], null);
		}

		// Token: 0x06001043 RID: 4163 RVA: 0x00068258 File Offset: 0x00066458
		public override void OnInput(H_INPUT input)
		{
			if (input == H_INPUT.CLICK_PAD)
			{
				this.Next();
			}
		}

		// Token: 0x06001044 RID: 4164 RVA: 0x00068268 File Offset: 0x00066468
		private void UpdateSE(float speed)
		{
			Female female = this.members.GetFemale(0);
			float delay = this.members.h_scene.se.Delay;
			float num = female.body.Anime.GetCurrentAnimatorStateInfo(0).normalizedTime + delay;
			float num2 = this.seTimer;
			if (this.seTimer == -1f || num % 1f < num2 % 1f)
			{
				if (this.members.StyleData.type == H_StyleData.TYPE.INSERT)
				{
					this.members.h_scene.se.Play_Piston(female, speed);
				}
				else if (this.members.StyleData.type == H_StyleData.TYPE.PETTING && (this.members.StyleData.detailFlag & 16) != 0)
				{
					this.members.h_scene.se.Play_Crotch(female, speed);
				}
			}
			this.seTimer = num;
		}

		// Token: 0x0400117B RID: 4475
		private XTC_TYPE xtcType;

		// Token: 0x0400117C RID: 4476
		private float timer;

		// Token: 0x0400117D RID: 4477
		private float seTimer = -1f;

		// Token: 0x0400117E RID: 4478
		private float maxSpeed = 4f;

		// Token: 0x0400117F RID: 4479
		private float minSpeed = 0.5f;

		// Token: 0x0200026B RID: 619
		public struct SpurtMsg : H_State.Message
		{
			// Token: 0x06001045 RID: 4165 RVA: 0x00068360 File Offset: 0x00066560
			public SpurtMsg(XTC_TYPE type)
			{
				this.xtcType = type;
			}

			// Token: 0x04001180 RID: 4480
			public XTC_TYPE xtcType;
		}
	}
}
